<?php

function getUserId() {
    return session(C('USER_ID'));
}

function filterEmoji($str) {
 	$str = preg_replace_callback( '/./u',
	   			function (array $match) {
	    			return strlen($match[0]) >= 4 ? '' : $match[0];
	   			},
   			$str);
 	
 	if($str===''){
 	    $str = 'Wechat_User';
 	}
  	return $str;
}

function wx_share_init(){

    $wxconfig = array();

    vendor('WXShare.class#jssdk');

    $jssdk =new JSSDK(C("WECHAT_PUBLIC_ACCOUNT_APPID"), C("WECHAT_PUBLIC_ACCOUNT_SECRET"));

    $wxconfig = $jssdk->GetSignPackage();

    return $wxconfig;
}
function isWechatBrowser() {
	if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
        return true;
    } else {
        return false;
    }
}